public class peakIndexInMountainArray {
    public static void main(String[] args) {
    int[] test1 = new int[]{1,2,3,4,5,4,3,2,1};
    int ret = peakIndexInMountainArray1(test1);
        System.out.println(ret);
}
    public static int peakIndexInMountainArray1(int[] arr) {
        int left = 0;
        int right = arr.length - 1;
        int max = arr[left] > arr[right] ? left:right;
        while(left < right){
            int mid = (right - left)/2 + left;
            //int mid = (right + left)/2;
            if(arr[mid] > arr[mid + 1]){
                max = mid;
                right = mid;

            }else{
                left = mid + 1;
            }
        }
        return max;
    }
}
